package com.apes.scm.masterdata.party.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @description: 客户业务关系
 * @author: wsj
 * @time: 2020/7/9 16:52
 */
@Getter
@Setter
@SelectBeforeUpdate
@Entity
@Table(name = CustomerBusiness.CONST_TABLE_NAME)
@DynamicInsert
@DynamicUpdate
@EntityListeners(DefaultPersistListener.class)
public class CustomerBusiness extends Model {
    public  static  final String  CONST_TABLE_NAME= "mas_customer_business";

    @Id
    @Column(name = "id")
    @Comment("唯一编码")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "接入商")
    private String id; //接入商ID


    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumn(name = "access_Provider", referencedColumnName = "id")
    @Comment("接入商")
    private AccessProvider accessProvider;

    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumn(name = "client_id", referencedColumnName = "id")
    @Comment("客户")
    private PartyRole client;

    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumn(name = "business_Type", referencedColumnName = "id")
    @Comment("业务类型")
    private Enumeration businessType;

    @Comment("有效标记")
    @Column(name = "valid",columnDefinition = ApesConst.FIELD_BOOLEAN_TRUE)
    private boolean valid ;
}
